package com.gpt.article.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.domain.entity.GptSpiderClass;
import com.gpt.article.service.IGptSpiderClassService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 分类列表Controller
 * 
 * @author zhuzi
 * @date 2023-10-25
 */
@RestController
@RequestMapping("/article/class")
public class GptSpiderClassController extends BaseController
{
    @Autowired
    private IGptSpiderClassService gptSpiderClassService;

    /**
     * 查询分类列表列表
     */
    @PreAuthorize("@ss.hasPermi('article:class:list')")
    @GetMapping("/list")
    public AjaxResult list(GptSpiderClass gptSpiderClass)
    {
        List<GptSpiderClass> list = gptSpiderClassService.selectGptSpiderClassList(gptSpiderClass);
        return success(list);
    }

    /**
     * 导出分类列表列表
     */
    @PreAuthorize("@ss.hasPermi('article:class:export')")
    @Log(title = "分类列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GptSpiderClass gptSpiderClass)
    {
        List<GptSpiderClass> list = gptSpiderClassService.selectGptSpiderClassList(gptSpiderClass);
        ExcelUtil<GptSpiderClass> util = new ExcelUtil<GptSpiderClass>(GptSpiderClass.class);
        util.exportExcel(response, list, "分类列表数据");
    }

    /**
     * 获取分类列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('article:class:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gptSpiderClassService.selectGptSpiderClassById(id));
    }

    /**
     * 新增分类列表
     */
    @PreAuthorize("@ss.hasPermi('article:class:add')")
    @Log(title = "分类列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GptSpiderClass gptSpiderClass)
    {
        return toAjax(gptSpiderClassService.insertGptSpiderClass(gptSpiderClass));
    }

    /**
     * 修改分类列表
     */
    @PreAuthorize("@ss.hasPermi('article:class:edit')")
    @Log(title = "分类列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GptSpiderClass gptSpiderClass)
    {
        return toAjax(gptSpiderClassService.updateGptSpiderClass(gptSpiderClass));
    }

    /**
     * 删除分类列表
     */
    @PreAuthorize("@ss.hasPermi('article:class:remove')")
    @Log(title = "分类列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gptSpiderClassService.deleteGptSpiderClassByIds(ids));
    }



}
